package com.atguigu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRedissonConfig {

    /**
     * 所有对redisson的使用都是通过RedissonClient对象
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson(){
        //创建配置
        Config config = new Config();
//        config.useClusterServers().addNodeAddress(); //集群时使用
        config.useSingleServer().setAddress("redis://192.168.211.130:6379");
        //根据config创建出RedissonClient示列
        return Redisson.create(config);
    }
}
